<?php
mysql_connect("127.0.0.1","root","sd2013");
mysql_select_db("mathRomp");
//Check to see if all students have completed the assignment. If so, then set the assignment as completed
$q2=mysql_query("SELECT count(*) as total FROM `Assignment` WHERE assignmentId=16 AND numProblems=currentProbNum");
$g=mysql_fetch_assoc($q2);
//echo $g['total'];
//print(json_encode($output1));

$q3=mysql_query("SELECT numStudents FROM `Assignment-Teacher` WHERE assignmentId=16");
 while($e=mysql_fetch_assoc($q3)){
      $output=$e;
    }
$f=json_encode($output);
$h=json_decode($f);
//echo $h->numStudents;

if($h->numStudents == $g['total']){
  $q4=mysql_query("UPDATE `Assignment-Teacher` SET completed=1 WHERE assignmentId=16");
  $i=mysql_fetch_assoc($q4);
}else{
  echo "Not all students have compelted assignment";
}
?>